package com.wangbo.strategy;

/**
 * 策略模式
 */
public class Client {
    public static void main(String[] args) {
        // 策略一：相加
        Scenario scenario = new Scenario().setStrategy(new OperationAdd());
        System.out.printf("10+5=%d%n", scenario.operate(10, 5));

        // 策略二：相乘
        scenario.setStrategy(new OperationMultiply());
        System.out.printf("10*5=%d%n", scenario.operate(10, 5));

        // 策略三：相减
        scenario.setStrategy(new OperationSubtract());
        System.out.printf("10-5=%d%n", scenario.operate(10, 5));
    }
}
